/**
 * Created by tanweiping on 2018/10/10.
 */

var columns = [
    {
        field: 'index',
        title: '序号',
        align:"center",
        formatter:function(value, row, index){
            return index + 1 + (row.pageNumber-1)*row.pageSize;
        }
    },
    {
        field: 'lessonName',
        align:"center",
        title: '套餐名称',
        formatter:function(value, row, index){
            return row.lessonName.length <=20 ? row.lessonName : row.lessonName.substring(0,20)+"...";
        }
    },
    {
        field: 'startDate',
        align:"center",
        title: '开始日期',
    },
    {
        field: 'endDate',
        align:"center",
        title: '结束日期'
    },
    {
        field: 'price',
        align:"center",
        title: '价格'
    },
    {
        field: 'groupPrice',
        align:"center",
        title: '团购价'
    },
    {
        field: 'state',
        align:"center",
        title: '状态',
        formatter: function (value, row, index) {
            return row.state=='0'?'无效':'有效';
        }
    },{
        field: 'mDesc',
        align:"center",
        title: '套餐描述',
        formatter:function(value, row, index){
            return row.mDesc.length <=20 ? row.mDesc : row.mDesc.substring(0,20)+"...";
        }
    },
    {
        field: 'operator',
        align:"center",
        title: '操作',
        formatter: function (value, row, index) {
            return pubOptBtn.getOptBtn('lesson',menu,row.id);
        }
    }];

var lesson={
    roleInit:function() {
        pubOptBtn.getHeadBtn("p","#toolbar","lesson",menu);
        pubForm.getBootTable("#tableList","/lesson/queryList","/role/updateState","meal");
    },
    showAddMealPage:function(){
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/lesson/showAddMealPage?lessonType=meal&menuId="+menuId
        });
    },
    updateMealPage:function (lessonId) {
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/lesson/updateMealPage?lessonType=meal&lessonId="+lessonId+"&menuId="+menuId
        });
    },
    showMealPage:function(lessonId){
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/lesson/showMealPage?lessonType=meal&lessonId="+lessonId+"&menuId="+menuId
        });
    },
    // //打开添加页面
    // showAddObjPage:function () {
    //     $.ajax({
    //         url: application.contextPath+"/role/showAddRolePage",
    //         type:"GET",
    //         success:function(res){
    //             layer.open({
    //                 type:1,
    //                 title:'角色管理',
    //                 content:res,
    //                 maxmin:true,//最大，最小开关
    //                 shade:0.5,//遮盖层模糊度
    //                 anim:1,//打开跟关闭动画
    //                 scrollbar:true,//是否设置滚轮
    //                 area:["880px","550px"]
    //             })
    //         }
    //     });
    // },
    deleteMealById:function (roleId) {
        pubForm.delRow(roleId,"/lesson/deleteMealById","/lesson/queryList","#tableList");
    }
};

$(document).ready(function(){
    lesson.roleInit();
});